﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Main
{
    class Account
    {

        public Account(string loginId,ListViewItem item)
        {


            this.listViewItem = item;
            this.loginId = loginId;

            item.Name = loginId;
            item.Text = loginId;

            ListViewItem.ListViewSubItem subItem1 = new ListViewItem.ListViewSubItem();
            subItem1.Name = "密码";
            subItem1.Text = password;

            ListViewItem.ListViewSubItem subItem2 = new ListViewItem.ListViewSubItem();
            subItem2.Name = "金额";
            subItem2.Text = money;

            ListViewItem.ListViewSubItem subItem3 = new ListViewItem.ListViewSubItem();
            subItem3.Name = "状态";
            subItem3.Text = this.getStatusText();


            item.SubItems.Add(subItem1);
            item.SubItems.Add(subItem2);
            item.SubItems.Add(subItem3);

        }


        public string getStatusText()
        {
            if(this.status == 0)
            {
                return "准备";
            }
            else if(this.status == 1)
            {
                return "检测中";
            }
            else if (this.status == 2)
            {
                return "成功";
            }
            else if(this.status == 3)
            {
                return "失败";
            }
            return "未知";
        }

        private string loginId;
        private string password;
        private string money;
        private int status;

        private ListViewItem listViewItem;


        public ListViewItem ListItem
        {
            get
            {
                return this.listViewItem;
            }
        }

        public string LoginId
        {
            get
            {
                return this.loginId;
            }
            set
            {
                this.loginId = value;
                this.listViewItem.Name = value;
                this.listViewItem.Text = value;
            }
        }

        public string Password
        {
            get
            {
                return this.password;
            }

            set
            {
                this.password = value;
                this.listViewItem.SubItems["密码"].Text = value;
            }
        }

        public string Money
        {
            get
            {
                return this.money;
            }

            set
            {
                this.money = value;
                this.listViewItem.SubItems["金额"].Text = value;
            }
        }

        public int Status
        {
            get
            {
                return this.status;
            }

            set
            {
                this.status = value;
                this.listViewItem.SubItems["状态"].Text = this.getStatusText();
                if (status == 2)
                {
                    this.listViewItem.BackColor = System.Drawing.Color.Green;
                    this.listViewItem.ForeColor = System.Drawing.Color.White;
                }

                if(status == 3)
                {
                    this.listViewItem.BackColor = System.Drawing.Color.Gray;
                    this.listViewItem.ForeColor = System.Drawing.Color.White;
                }
            }
        }


    }
}
